package com.aaa.controller.scl;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.mht.ViewTestResultmht;
import com.aaa.entity.sas.ViewTestResultSas;
import com.aaa.entity.scl.ViewTestResultScl;
import com.aaa.service.mht.ViewTestResultService;
import com.aaa.service.scl.ViewTestResultSclService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Mht视图表控制层
 *
 * @author makejava
 * @since 2022-09-02 20:01:28
 */
@RestController
@RequestMapping("viewTestResultScl")
public class ViewTestResultSclController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ViewTestResultSclService viewTestResultSclService;




    @RequestMapping(value = "queryAllByCondition.do",method = RequestMethod.GET)
    public Result queryAllByCondition(PageSortEntity pageSortEntity, ViewTestResultScl viewTestResultScl){
        List<ViewTestResultScl> viewTestResultSclList = viewTestResultSclService.queryAllByCondition(pageSortEntity, viewTestResultScl);
        Page page = (Page) viewTestResultSclList;

        return success(page.getResult(),page.getTotal());
    }
    /**
     * 删除计划
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping(value = "delViewSclById.do")
    public Result deleteById(Integer id) {
        Boolean i = viewTestResultSclService.deleteById(id);
        if ( i ){
            return success();
        }else {
            return fail();
        }
    }

    /**
     *  批量删除计划
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping(value = "delViewSclAllById.do")
    public Result deleteBatch(int [] id) {
        Integer integer = viewTestResultSclService.delTestPlanBatch(id);
        if (integer>0){
            return success();
        }else {
            return fail();
        }
    }

    /**
     * 报表统计
     * @return
     */
    @RequestMapping("showResult.do")
    public Result showResult() {
        Map<String, Integer> stringIntegerMap = viewTestResultSclService.queryAll();
        return success(stringIntegerMap);
    }

    /**
     * 单条结果显示
     */
    @RequestMapping("queryById.do")
    public Result queryResultById(ViewTestResultScl viewTestResultScl) {
        ViewTestResultScl viewTestResultScl1 = viewTestResultSclService.queryById(viewTestResultScl);
        return success(viewTestResultScl1);
    }

}

